package com.zlll.winner.service.lhtUser;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zlll.winner.business.model.lhtUser.LhtUserIdentity;
import com.zlll.winner.mapper.lhtUser.LhtUserIdentityMapper;
import com.zlll.winner.business.service.lhtUser.ILhtUserIdentityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.Service;

import java.util.List;

/**
 * <p>
 * 用户身份关联表 服务实现类
 * </p>
 *
 * @author qsx
 * @since 2019-09-05
 */
@Service
public class LhtUserIdentityServiceImpl extends ServiceImpl<LhtUserIdentityMapper, LhtUserIdentity> implements ILhtUserIdentityService {


    @Override
    public Boolean deleteLhtUserIdentity(Long userId) {
        Long time = System.currentTimeMillis();
        LambdaQueryWrapper<LhtUserIdentity> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(LhtUserIdentity::getIsDel, 0);
        wrapper.eq(LhtUserIdentity::getUserId, userId);

        List<LhtUserIdentity> lhtUserIdentities = list(wrapper);
        for (LhtUserIdentity lhtUserIdentity : lhtUserIdentities) {
            lhtUserIdentity.setIsDel(1);
            lhtUserIdentity.setUpdateTime(time);
        }
        if (lhtUserIdentities.size() > 0) {
            return saveOrUpdateBatch(lhtUserIdentities);
        }
        return true;
    }
}
